package com.soloyogame.anitoys.center.web.util;

import com.soloyogame.anitoys.db.bean.User;
import com.soloyogame.anitoys.db.commond.Account;
import com.soloyogame.anitoys.util.constants.ManageContainer;
import com.soloyogame.anitoys.util.front.FrontContainer;
import org.apache.commons.lang.StringUtils;

import javax.servlet.http.HttpSession;

/**
 * Created by shaojian on 15-11-30.
 */
public class LoginUserHolder 
{
	public static User getLoginUser()
    {
        HttpSession session = RequestHolder.getSession();
        return session == null ? null : (User)session.getAttribute(ManageContainer.center_session_user_info);
    }
    
    public static Account getLoginAccount()
    {
        HttpSession session = RequestHolder.getSession();
        Account account = (Account)session.getAttribute(FrontContainer.USER_INFO);
        if(account != null && StringUtils.isBlank(account.getId())) {
        	account.setId(account.getId());
        	session.setAttribute(FrontContainer.USER_INFO, account);
        } 
        return session == null ? null : account;
    }
}
